package arrays

// FilterBy 根据自定义条件函数过滤元素
func FilterBy[T any](array []T, fn func(T, int, []T) bool) []T {
	var result []T

	for i, v := range array {
		if fn(v, i, array) {
			result = append(result, v)
		}
	}

	return result
}
